package com.yanqu.road.server.channelserver.cmd.chat;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.worldmessage.WorldMessageProto;
import com.yanqu.road.server.channelserver.cmd.ChannelCommand;
import com.yanqu.road.server.channelserver.manager.activity.ChannelActivityInfoMgr;
import com.yanqu.road.server.channelserver.manager.activity.tonbing.ChannelTonBingMgr;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.N_CHANNEL_CLEAR_CHAT, desc = "")
public class ChannelClearChatCmd extends ChannelCommand {

    private WorldMessageProto.SyncClearChatMsg reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = WorldMessageProto.SyncClearChatMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = ChannelActivityInfoMgr.getActivityInfo(reqMsg.getActivityId());
        if(activityInfo.getType() == eActivityType.ChannelTonBingActivity.getValue()){
            ChannelTonBingMgr.getLogger().error("清空跨域统兵{}的聊天",reqMsg.getActivityId());
            ChannelTonBingMgr.getActivity(activityInfo.getActivityId()).clearChat();
        }
    }

    @Override
    public void sendData() {

    }
}
